package com.tx.review.thread_.state;

/**
 * 守护线程测试
 *
 * @author ：tx
 * @version:
 */
public class DaemonTest {
    public static void main(String[] args) {
        Thread god = new Thread(new God());
        Thread person = new Thread(new Person());

        //设置为守护线程
        god.setDaemon(true);

        god.start();
        person.start();
    }


    static class God implements Runnable{
        @Override
        public void run() {
            while (true){
                System.out.println("I am god");
            }
        }
    }


    static class Person implements Runnable{
        @Override
        public void run() {
            for (int i = 0; i < 36500; i++) {
                System.out.println("I'm person");
            }
        }
    }
}
